﻿<Application x:Class="SampleApplication.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:wpfToolkit="clr-namespace:System.Windows.Controls;assembly=PresentationFramework"
             xmlns:wpfToolKitPrimitives="clr-namespace:System.Windows.Controls.Primitives;assembly=PresentationFramework"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
        <SolidColorBrush x:Key="selectedItemBrush" Color="#FFF0C2" />
        <SolidColorBrush x:Key="gridForeground" Color="Black" />
        <SolidColorBrush x:Key="alternateRowBrush" Color="#F6FAFD" />
        <SolidColorBrush x:Key="gridLineBrush" Color="#D3D3D3" />
        <SolidColorBrush x:Key="controlBorderBrush" Color="#7F9DB9" />
        <SolidColorBrush x:Key="standardTextForegroundColor" Color="#15428B" />

        <SolidColorBrush x:Key="ToolBarButtonHover" Color="#C2E0FF"/>

        <SolidColorBrush x:Key="ToolBarGripper" Color="Black"/>

        <SolidColorBrush x:Key="ToolBarSubMenuBackground" Color="#FDFDFD"/>

        <SolidColorBrush x:Key="ToolBarMenuBorder" Color="#808080"/>
        <LinearGradientBrush x:Key="standardBackgroundGradient"  StartPoint="0,0" EndPoint="1,1">
            <GradientStop Color="#BFDBFF"   Offset="0"/>
            <GradientStop Color="White"   Offset=".2"/>
            <GradientStop Color="#BFDBFF"   Offset="1"/>
        </LinearGradientBrush>
        <LinearGradientBrush x:Key="standardHeaderBackgroundGradient" StartPoint="0,1" EndPoint="0,0">
            <GradientStop Color="#BFDBFF" Offset="0"/>
            <GradientStop Color="#FFFFFF" Offset=".95"/>
        </LinearGradientBrush>

        <LinearGradientBrush x:Key="ToolBarVerticalBackground" EndPoint="1,0" StartPoint="0,0">
            <GradientStop Color="#FFFFFF" Offset="0"/>
            <GradientStop Color="#FFFBFF" Offset="0.5"/>
            <GradientStop Color="#F7F7F7" Offset="1"/>
        </LinearGradientBrush>

        <LinearGradientBrush x:Key="ToolBarToggleButtonHorizontalBackground" StartPoint="0,1" EndPoint="0,0">
            <GradientStop Color="#6F9DD9" Offset="0"/>
            <GradientStop Color="#D3E6FF" Offset="1"/>
        </LinearGradientBrush>

        <LinearGradientBrush x:Key="ToolBarToggleButtonVerticalBackground" EndPoint="1,0" StartPoint="0,0">
            <GradientStop Color="#ECECEC" Offset="0"/>
            <GradientStop Color="#DDDDDD" Offset="0.5"/>
            <GradientStop Color="#A0A0A0" Offset="1"/>
        </LinearGradientBrush>

        <Style TargetType="Control" x:Key="windowStyle">
            <Setter Property="Background" Value="{StaticResource standardBackgroundGradient}"/>
            <Setter Property="Foreground" Value="{StaticResource standardTextForegroundColor}"/>
        </Style>

        <Style TargetType="StatusBarItem">
            <Setter Property="Foreground" Value="{StaticResource standardTextForegroundColor}"/>
            <Setter Property="FontFamily" Value="Tahoma"/>
            <Setter Property="FontSize" Value="8.25pt"/>
            <Setter Property="Background" Value="{StaticResource standardHeaderBackgroundGradient}"/>
        </Style>

        <Style TargetType="StatusBar">
            <Setter Property="Background" Value="{StaticResource standardHeaderBackgroundGradient}"/>
        </Style>

        <Style x:Key="ToolBarThumbStyle" TargetType="{x:Type Thumb}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Thumb}">
                        <Border SnapsToDevicePixels="True" Background="Transparent" Padding="{TemplateBinding Padding}">
                            <Rectangle>
                                <Rectangle.Fill>
                                    <DrawingBrush TileMode="Tile" Viewbox="0,0,4,4" ViewboxUnits="Absolute" Viewport="0,0,4,4" ViewportUnits="Absolute">
                                        <DrawingBrush.Drawing>
                                            <DrawingGroup>
                                                <GeometryDrawing Brush="White" Geometry="M 1 1 L 1 3 L 3 3 L 3 1 z"/>
                                                <GeometryDrawing Brush="{StaticResource ToolBarGripper}" Geometry="M 0 0 L 0 2 L 2 2 L 2 0 z"/>
                                            </DrawingGroup>
                                        </DrawingBrush.Drawing>
                                    </DrawingBrush>
                                </Rectangle.Fill>
                            </Rectangle>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="true">
                                <Setter Property="Cursor" Value="SizeAll"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>



        <Style x:Key="columnHeaderStyle" TargetType="{x:Type wpfToolKitPrimitives:DataGridColumnHeader}" 
           BasedOn="{StaticResource {x:Type wpfToolKitPrimitives:DataGridColumnHeader}}">
            <!--<Setter Property="BorderThickness" Value="1" />-->
            <!--<Setter Property="BorderBrush" Value="{StaticResource controlBorderBrush}"/>-->
            <!--<Setter Property="TextBlock.Padding" Value="1"/>-->
            <Setter Property="Foreground" Value="{StaticResource standardTextForegroundColor}"/>
            <!--<Setter Property="Background" Value="{StaticResource standardHeaderBackgroundGradient}"/>-->
        </Style>


        <Style TargetType="{x:Type wpfToolkit:DataGrid}">

            <Setter Property="RowBackground" Value="White"/>
            <Setter Property="AlternatingRowBackground" Value="{StaticResource alternateRowBrush}"/>
            <Setter Property="Margin" Value="2"/>
            <Setter Property="Background" Value="White"/>
            <Setter Property="VerticalGridLinesBrush" Value="{StaticResource gridLineBrush}"/>
            <Setter Property="HorizontalGridLinesBrush" Value="{StaticResource gridLineBrush}"/>
            <Setter Property="RowHeaderWidth" Value="0"/>
            <Setter Property="ColumnHeaderStyle" Value="{StaticResource columnHeaderStyle}"/>
            <Setter Property="CanUserSortColumns" Value="True"/>

            <Setter Property="CellStyle">
                <Setter.Value>
                    <Style TargetType="wpfToolkit:DataGridCell">
                        <Style.Triggers>

                            <Trigger Property="IsSelected" Value="True">
                                <Setter Property="Background" Value="{StaticResource selectedItemBrush}" />
                                <Setter Property="TextBox.Background" Value="{StaticResource selectedItemBrush}" />
                                <Setter Property="BorderBrush" Value="{StaticResource selectedItemBrush}" />
                                <Setter Property="Foreground" Value="{StaticResource gridForeground}" />
                            </Trigger>
                            <Trigger Property="Validation.HasError" Value="true">
                                <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}"/>
                            </Trigger>

                        </Style.Triggers>


                        <Setter Property="Padding" Value="4,3,4,3" />
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="wpfToolkit:DataGridCell">
                                    <Border Padding="{TemplateBinding Padding}"
                                Background="{TemplateBinding Background}">
                                        <ContentPresenter />
                                    </Border>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </Setter.Value>
            </Setter>
            <Setter Property="RowStyle">
                <Setter.Value>
                    <Style TargetType="wpfToolkit:DataGridRow">
                        <Style.Triggers>

                            <Trigger Property="IsSelected" Value="True">
                                <Setter Property="Background" Value="{StaticResource selectedItemBrush}" />
                                <Setter Property="BorderBrush" Value="{StaticResource selectedItemBrush}" />
                                <Setter Property="Foreground" Value="{StaticResource gridForeground}" />
                            </Trigger>

                        </Style.Triggers>
                    </Style>
                </Setter.Value>
            </Setter>
        </Style>

        <Style TargetType="{x:Type ToolBarTray}" >
            <Setter Property="IsLocked" Value="True"/>
            <Setter Property="Background" Value="Transparent"/>
        </Style>

        <Style TargetType="{x:Type TextBlock}" x:Key="verticalToolbarTextBlockStyle">
            <Setter Property="TextAlignment" Value="Center"/>
            <Setter Property="HorizontalAlignment" Value="Right"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="Foreground" Value="{StaticResource standardTextForegroundColor}"/>
            <Setter Property="FontFamily" Value="Tahoma"/>
            <Setter Property="FontSize" Value="8.25pt"/>
        </Style>

        <Style x:Key="ToolBarVerticalOverflowButtonStyle" TargetType="{x:Type ToggleButton}">
            <Setter Property="Background" Value="{StaticResource ToolBarToggleButtonVerticalBackground}"/>
            <Setter Property="MinHeight" Value="0"/>
            <Setter Property="MinWidth" Value="0"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ToggleButton}">
                        <Border SnapsToDevicePixels="true" x:Name="Bd" Background="{TemplateBinding Background}" CornerRadius="0,0,3,3">
                            <Canvas SnapsToDevicePixels="true" HorizontalAlignment="Right" Margin="2,7,2,2" VerticalAlignment="Bottom" Width="7" Height="6">
                                <Path Stroke="White" Data="M 1.5 1 L 1.5 6"/>
                                <Path Stroke="{TemplateBinding Foreground}" Data="M 0.5 0 L 0.5 5"/>
                                <Path Fill="White" Data="M 3.5 0.5 L 7 3.5 L 4 6.5 Z"/>
                                <Path Fill="{TemplateBinding Foreground}" Data="M 3 -0.5 L 6 2.5 L 3 5.5 Z"/>
                            </Canvas>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="true">
                                <Setter Property="Background" TargetName="Bd" Value="{StaticResource ToolBarButtonHover}"/>
                            </Trigger>
                            <Trigger Property="IsKeyboardFocused" Value="true">
                                <Setter Property="Background" TargetName="Bd" Value="{StaticResource ToolBarButtonHover}"/>
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Foreground" Value="{StaticResource ToolBarGripper}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="ToolBarHorizontalOverflowButtonStyle" TargetType="{x:Type ToggleButton}">
            <Setter Property="Background" Value="{StaticResource ToolBarToggleButtonHorizontalBackground}"/>
            <Setter Property="MinHeight" Value="0"/>
            <Setter Property="MinWidth" Value="0"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ToggleButton}">
                        <Border SnapsToDevicePixels="true" x:Name="Bd" Background="{TemplateBinding Background}" CornerRadius="0,3,3,0">
                            <Canvas SnapsToDevicePixels="true" HorizontalAlignment="Right" Margin="7,2,2,2" VerticalAlignment="Bottom" Width="6" Height="7">
                                <Path Stroke="White" Data="M 1 1.5 L 6 1.5"/>
                                <Path Stroke="{TemplateBinding Foreground}" Data="M 0 0.5 L 5 0.5"/>
                                <Path Fill="White" Data="M 0.5 4 L 6.5 4 L 3.5 7 Z"/>
                                <Path Fill="{TemplateBinding Foreground}" Data="M -0.5 3 L 5.5 3 L 2.5 6 Z"/>
                            </Canvas>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="true">
                                <Setter Property="Background" TargetName="Bd" Value="{StaticResource ToolBarButtonHover}"/>
                            </Trigger>
                            <Trigger Property="IsKeyboardFocused" Value="true">
                                <Setter Property="Background" TargetName="Bd" Value="{StaticResource ToolBarButtonHover}"/>
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Foreground" Value="{StaticResource ToolBarGripper}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style  TargetType="{x:Type ToolBar}">
            <Setter Property="Background" Value="{StaticResource standardHeaderBackgroundGradient}"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ToolBar}">
                        <Grid SnapsToDevicePixels="true" Margin="3,1,1,1" x:Name="Grid">
                            <Grid HorizontalAlignment="Right" x:Name="OverflowGrid">
                                <ToggleButton IsEnabled="{TemplateBinding HasOverflowItems}" FocusVisualStyle="{x:Null}" x:Name="OverflowButton" Style="{StaticResource ToolBarHorizontalOverflowButtonStyle}" ClickMode="Press" IsChecked="{Binding Path=IsOverflowOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"/>
                                <Popup Focusable="false" AllowsTransparency="true" IsOpen="{Binding Path=IsOverflowOpen, RelativeSource={RelativeSource TemplatedParent}}" Placement="Bottom" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" StaysOpen="false" x:Name="OverflowPopup">
                                    <Border Background="{StaticResource ToolBarSubMenuBackground}" BorderBrush="{StaticResource ToolBarMenuBorder}" BorderThickness="1">
                                        <ToolBarOverflowPanel Focusable="true" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" FocusVisualStyle="{x:Null}" Margin="2" x:Name="PART_ToolBarOverflowPanel" KeyboardNavigation.DirectionalNavigation="Cycle" KeyboardNavigation.TabNavigation="Cycle" WrapWidth="200"/>
                                    </Border>
                                </Popup>
                            </Grid>
                            <Border Margin="0,0,11,0" x:Name="MainPanelBorder" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="3,3,3,3" Padding="{TemplateBinding Padding}">
                                <DockPanel KeyboardNavigation.TabIndex="1" KeyboardNavigation.TabNavigation="Local">
                                    <Thumb Padding="6,5,1,6" Margin="-3,-1,0,0" x:Name="ToolBarThumb" Style="{StaticResource ToolBarThumbStyle}" Width="10"/>
                                    <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="Center" Margin="4,0,4,0" x:Name="ToolBarHeader" VerticalAlignment="Center" ContentSource="Header"/>
                                    <ToolBarPanel SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="0,1,2,2" x:Name="PART_ToolBarPanel" IsItemsHost="true"/>
                                </DockPanel>
                            </Border>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsOverflowOpen" Value="true">
                                <Setter Property="IsEnabled" TargetName="ToolBarThumb" Value="false"/>
                            </Trigger>
                            <Trigger Property="Header" Value="{x:Null}">
                                <Setter Property="Visibility" TargetName="ToolBarHeader" Value="Collapsed"/>
                            </Trigger>
                            <Trigger Property="ToolBarTray.IsLocked" Value="true">
                                <Setter Property="Visibility" TargetName="ToolBarThumb" Value="Collapsed"/>
                            </Trigger>
                          
                            <Trigger Property="Orientation" Value="Vertical">
                                <Setter Property="Margin" TargetName="Grid" Value="1,3,1,1"/>
                                <Setter Property="Style" TargetName="OverflowButton" Value="{StaticResource ToolBarVerticalOverflowButtonStyle}"/>
                                <Setter Property="Height" TargetName="ToolBarThumb" Value="10"/>
                                <Setter Property="Width" TargetName="ToolBarThumb" Value="Auto"/>
                                <Setter Property="Margin" TargetName="ToolBarThumb" Value="-1,-3,0,0"/>
                                <Setter Property="Padding" TargetName="ToolBarThumb" Value="5,6,6,1"/>
                                <Setter Property="Margin" TargetName="ToolBarHeader" Value="0,0,0,4"/>
                                <Setter Property="Margin" TargetName="PART_ToolBarPanel" Value="1,0,2,2"/>
                                <Setter Property="DockPanel.Dock" TargetName="ToolBarThumb" Value="Top"/>
                                <Setter Property="DockPanel.Dock" TargetName="ToolBarHeader" Value="Top"/>
                                <Setter Property="HorizontalAlignment" TargetName="OverflowGrid" Value="Stretch"/>
                                <Setter Property="VerticalAlignment" TargetName="OverflowGrid" Value="Bottom"/>
                                <Setter Property="Placement" TargetName="OverflowPopup" Value="Right"/>
                                <Setter Property="Margin" TargetName="MainPanelBorder" Value="0,0,0,11"/>
                                <Setter Property="Background" Value="{StaticResource ToolBarVerticalBackground}"/>
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="headerOverrideMenuItemStyle"
       TargetType="MenuItem">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="MenuItem">
                        <ContentPresenter 

                                         ContentSource="Header"/>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style TargetType="{x:Type Image}" x:Key="verticalToolbarImageStyle">
            <Style.Triggers>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type Button}, AncestorLevel=1}, Path=IsEnabled}" Value="False">
                    <Setter Property="Opacity" Value="0.50"></Setter>
                </DataTrigger>
            </Style.Triggers>
            <Setter Property="Height" Value="16"/>
            <Setter Property="Width" Value="16"/>
            <Setter Property="Stretch" Value="UniformToFill" />
        </Style>
        <Style x:Key="headerStyle" TargetType="Control">
            <Setter Property="Background" Value="{StaticResource standardHeaderBackgroundGradient}"/>
            <Setter Property="Foreground" Value="{StaticResource standardTextForegroundColor}"/>
            <Setter Property="FontSize" Value="18"/>
            <Setter Property="FontFamily" Value="Calibri"/>
            <Setter Property="FontWeight" Value="ExtraBold"/>
        </Style>
        <Style  TargetType="Label" >
            <Setter Property="Foreground" Value="{StaticResource standardTextForegroundColor}"/>
        </Style>
 
        <Style TargetType="ComboBox">
            <Setter Property="BorderBrush" Value="{StaticResource controlBorderBrush}"/>
            <Setter Property="Margin" Value="2"/>
            <Setter Property="HorizontalAlignment" Value="Left"/>
            <Setter Property="Width" Value="200"/>
        </Style>
    </Application.Resources>
</Application>
